package xyz.labmem.base.sys.config.mybatis

import com.baomidou.mybatisplus.annotation.DbType
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor
import org.mybatis.spring.annotation.MapperScan
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.transaction.annotation.EnableTransactionManagement

/**
 * @Author lty
 * @Date 2021/12/14 15:58
 */
@Configuration
@EnableTransactionManagement
@MapperScan("xyz.labmem.**.mapper.**")
class MyBatisPlusConfiguration {

    //分页
    @Bean
    fun mybatisPlusInterceptor(): MybatisPlusInterceptor? {
        val interceptor = MybatisPlusInterceptor()
        interceptor.addInnerInterceptor(PaginationInnerInterceptor(DbType.MYSQL))
        return interceptor
    }


    @Bean
    fun easySqlInjector(): EasySqlInjector = EasySqlInjector()

}